$title Household model

$ontext
--------------------------------------------------------------------------------
Closed 2x2 economy with multiple households.
Laurent Cretegny, CoPS, Monash University, Australia, 2003.
--------------------------------------------------------------------------------
$offtext

$set path d:\prof\research\mpsge\mge2gem\examples\mpsge\hh

sets
  h                 household                     / hh, fh /
  o                 commodity and sector          / agr, ind /
  f                 primary factor                / lab, cap /;

alias(o,s);

parameters
  sam(*,*)          benchmark social accounting matrix
  factor(f,s)       factor demand
  interm(o,s)       intermediate demand
  demand(o,h)       demand for consumption
  endowdem(f,h)     endowment demand for household
  endow(f,h)        endowment
  govdem(o)         government demand
  tr_y(s)           tax revenue on output
  tr_w(f,h)         tax revenue on endowment
  esv(s)            elasticity of substitution in value-added
  esc(h)            elasticity of substitution in consumption
  esd(h)            elasticity of substitution in demand
  supply(s)         supply of output
  cons              aggregate consumption
  govcons           aggregate government consumption
  endowfac(f,h)     endowment for primary factor (gross of tax)
  endowsup(f,h)     endowment supply by household
  t_y(s)            tax rate on output
  t_w(f,h)          tax rate on endowment
  t_y_l(s)          power of tax on output
  t_w_l(f,h)        power of tax on endowment;

$call gdxxrw i=%path%\hh.xls o=%path%\hh.gdx index=declare
$gdxin %path%\hh.gdx
$load sam = sam
$load esv = esv
$load esc = esc
$load esd = esd
$gdxin

factor(f,s) = sam(f,s);
interm(o,s) = sam(o,s);
demand(o,h) = sam(o,h);
endowdem(f,h) = sam(f,h);
endow(f,h) = sam(h,f);
govdem(o) = sam(o,"gov");
tr_y(s) = sam("ty",s);
tr_w(f,"hh") = sam("tw_hh",f);
tr_w(f,"fh") = sam("tw_fh",f);
supply(s) = sum(o, interm(o,s)) + sum(f, factor(f,s)) + tr_y(s);
cons(h) = sum(o, demand(o,h));
govcons = sum(o, govdem(o));
endowfac(f,h) = endow(f,h) + tr_w(f,h) - endowdem(f,h);
endowsup(f,h) = endow(f,h) - endowdem(f,h);
t_y(s) = tr_y(s) / supply(s);
t_w(f,h) = tr_w(f,h) / endowfac(f,h);
t_y_l(s) = 1 - t_y(s);
t_w_l(f,h) = 1 - t_w(f,h);

$ontext
$model:hh

$sectors:
  y(s)              ! production
  u(h)              ! utility index
  g                 ! government expenditure
  w(f,h)            ! endowment supply index

$commodities:
  p(o)              ! price of commodity
  pu(h)             ! true cost-of-living index
  pg                ! price of a unit of government output
  pf(f)             ! price of primary factor
  pw(f,h)           ! price of endowment

$consumers:
  ra(h)             ! representative agent income
  gov               ! government income

$prod:y(s)          s:0.0               s.tl:esv(s)
  o:p(s)            q:supply(s)         p:t_y_l(s)          a:gov     t:t_y(s)
  i:pf(f)           q:factor(f,s)       s.tl:
  i:p(o)            q:interm(o,s)

$prod:u(h)          s:esc(h)            h.tl:esd(h)
  o:pu(h)           q:(cons(h)+sum(f,endowdem(f,h)))
  i:pw(f,h)         q:endowdem(f,h)
  i:p(o)            q:demand(o,h)       h.tl:

$prod:g
  o:pg              q:govcons
  i:p(o)            q:govdem(o)

$prod:w(f,h)
  o:pf(f)           q:endowfac(f,h)     p:t_w_l(f,h)        a:gov     t:t_w(f,h)
  i:pw(f,h)         q:endowsup(f,h)

$demand:ra(h)
  d:pu(h)           q:(cons(h)+sum(f,endowdem(f,h)))
  e:pw(f,h)         q:endow(f,h)

$demand:gov
  d:pg              q:govcons

$report:
  v:r_cons(o,h)     i:p(o)              prod:u(h)

$offtext
$sysinclude mpsgeset hh

* Benchmark replication

hh.iterlim = 0;
$include hh.gen
solve hh using mcp;
abort$(abs(hh.objval) gt 1e-7) "*** hh does not calibrate ! ***";
hh.iterlim = 1000;

* Fixation of a numeraire to allow comparison

ra.fx("hh") = ra.l("hh");

* Counterfactual : 10% increase in tax rate on labour income

t_w("lab",h) = t_w("lab",h) * 1.1;

$include hh.gen
solve hh using mcp;

* Results

parameters
  res_com           results by commodity in % change from basis
  res_agg           aggregate results in % change from basis; 

res_com("output",o) = (y.l(o) - 1) * 100;
res_com("price",o) = (p.l(o) - 1) * 100;

res_agg("u",h) = (u.l(h) - 1 ) * 100;
res_agg("pu",h) = (pu.l(h) - 1 ) * 100;
res_agg("ra_inc",h) = (ra.l(h)/(cons(h)+sum(f,endowdem(f,h))) - 1 ) * 100;

option decimals = 6;
display res_com, res_agg;
